package com.mao.extends5override;

public class Test2 {
    public static void main(String[] args) {
        //方法重写的常用场景：子类重写Object的toString方法，以便返回对象的内容。
        Student s = new Student("张三", '男', 18);
        System.out.println(s);
    }
}


class Student{
    private String name;
    private char sex;
    private int age;

    @Override
    public String toString() {
        return "Student [name=" + name + ", sex=" + sex + ", age=" + age + "]";
    }
    public Student(){}
    public Student(String name, char sex, int age){
        this.name = name;
        this.sex = sex;
        this.age = age;
    }
}